comm.sort(x, decreasing = FALSE, na.last = NA,
comm = .SPMD.CT$comm, status = .SPMD.CT$status)
NA
s.
If TRUE
, missing values in the data are put last;
if FALSE
, they are put first; if NA
,
they are removed.x
but in global sorting order.x
.# Save code in a file "demo.r" and run with 2 processors by
# > mpiexec -np 2 Rscript demo.r
### Initial
library(pbdMPI, quietly = TRUE)
init()
.comm.size <- comm.size()
.comm.rank <- comm.rank()
### Examples
comm.set.seed(diff = TRUE)
x <- c(rnorm(5 + .comm.rank * 2), NA)
# x <- sample(1:5, 5 + .comm.rank * 2, replace = TRUE)
comm.end.seed()
if(.comm.rank == 1){
x <- NULL ### Test for NULL or 0 vector.
}
y <- allgather(x)
comm.print(y)
y <- comm.sort(x)
y <- allgather(y)
comm.print(y)
### Finish
finalize()
Run the code above in your browser using DataLab